package com.example.bob.bundletest;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

public class MainActivity extends Activity {

    private TextView textView;
    private Button btnPut;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnPut = (Button)findViewById(R.id.btnPut);
        btnPut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(MainActivity.this,ResultActivity.class);
//                i.putExtra("message","PutMessage");

//                startActivity(i);
                Bundle bundle = new Bundle();
                bundle.putString("message","InputMessage");

                i.putExtras(bundle);

                startActivityForResult(i,0);
            }
        });
        textView = (TextView)findViewById(R.id.mainView);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        String result = data.getStringExtra("result");

        textView.setText(result);

        super.onActivityResult(requestCode, resultCode, data);
    }
}
